Also rename it from GskMatrixCategory to GskTransformCategory.
gsk_transform_ref
gsk_transform_unref
<SUBSECTION>
+GskTransformCategory
+gsk_transform_get_category
+<SUBSECTION>
gsk_transform_print
gsk_transform_to_string
gsk_transform_to_matrix
RenderOpBuilder *builder)
{
GskTransform *node_transform = gsk_transform_node_get_transform (node);
- const GskMatrixCategory category = gsk_transform_categorize (node_transform);
+ const GskTransformCategory category = gsk_transform_get_category (node_transform);
GskRenderNode *child = gsk_transform_node_get_child (node);
switch (category)
{
- case GSK_MATRIX_CATEGORY_IDENTITY:
+ case GSK_TRANSFORM_CATEGORY_IDENTITY:
gsk_gl_renderer_add_render_ops (self, child, builder);
break;
- case GSK_MATRIX_CATEGORY_2D_TRANSLATE:
+ case GSK_TRANSFORM_CATEGORY_2D_TRANSLATE:
{
float dx, dy;
}
break;
- case GSK_MATRIX_CATEGORY_2D_AFFINE:
+ case GSK_TRANSFORM_CATEGORY_2D_AFFINE:
{
graphene_matrix_t mat;
}
break;
- case GSK_MATRIX_CATEGORY_UNKNOWN:
- case GSK_MATRIX_CATEGORY_ANY:
- case GSK_MATRIX_CATEGORY_INVERTIBLE:
+ case GSK_TRANSFORM_CATEGORY_UNKNOWN:
+ case GSK_TRANSFORM_CATEGORY_ANY:
+ case GSK_TRANSFORM_CATEGORY_3D:
+ case GSK_TRANSFORM_CATEGORY_2D:
default:
{
const float min_x = child->bounds.origin.x;
op.op = OP_CLEAR;
ops_add (builder, &op);
prev_projection = ops_set_projection (builder, &item_proj);
- ops_set_modelview (builder, &identity, GSK_MATRIX_CATEGORY_IDENTITY);
+ ops_set_modelview (builder, &identity, GSK_TRANSFORM_CATEGORY_IDENTITY);
prev_viewport = ops_set_viewport (builder, &GRAPHENE_RECT_INIT (0, 0, texture_width, texture_height));
/* Draw outline */
op.op = OP_CLEAR;
ops_add (builder, &op);
prev_projection = ops_set_projection (builder, &item_proj);
- ops_set_modelview (builder, &identity, GSK_MATRIX_CATEGORY_IDENTITY);
+ ops_set_modelview (builder, &identity, GSK_TRANSFORM_CATEGORY_IDENTITY);
prev_viewport = ops_set_viewport (builder,
&GRAPHENE_RECT_INIT (bounds->origin.x * scale,
bounds->origin.y * scale,
render_op_builder.current_opacity = 1.0f;
render_op_builder.render_ops = self->render_ops;
ops_set_modelview (&render_op_builder, &modelview,
- scale_factor == 1 ? GSK_MATRIX_CATEGORY_IDENTITY : GSK_MATRIX_CATEGORY_2D_AFFINE);
+ scale_factor == 1 ? GSK_TRANSFORM_CATEGORY_IDENTITY : GSK_TRANSFORM_CATEGORY_2D_AFFINE);
/* Initial clip is self->render_region! */
if (self->render_region != NULL)
{
switch (md->category)
{
- case GSK_MATRIX_CATEGORY_IDENTITY:
+ case GSK_TRANSFORM_CATEGORY_IDENTITY:
md->scale_x = 1;
md->scale_y = 1;
break;
- case GSK_MATRIX_CATEGORY_2D_TRANSLATE:
+ case GSK_TRANSFORM_CATEGORY_2D_TRANSLATE:
md->translate_x = graphene_matrix_get_value (m, 3, 0);
md->translate_y = graphene_matrix_get_value (m, 3, 1);
md->scale_x = 1;
md->scale_y = 1;
break;
- case GSK_MATRIX_CATEGORY_UNKNOWN:
- case GSK_MATRIX_CATEGORY_ANY:
- case GSK_MATRIX_CATEGORY_INVERTIBLE:
- case GSK_MATRIX_CATEGORY_2D_AFFINE:
+ case GSK_TRANSFORM_CATEGORY_UNKNOWN:
+ case GSK_TRANSFORM_CATEGORY_ANY:
+ case GSK_TRANSFORM_CATEGORY_3D:
+ case GSK_TRANSFORM_CATEGORY_2D:
+ case GSK_TRANSFORM_CATEGORY_2D_AFFINE:
{
graphene_vec3_t col1;
graphene_vec3_t col2;
switch (head->metadata.category)
{
- case GSK_MATRIX_CATEGORY_IDENTITY:
+ case GSK_TRANSFORM_CATEGORY_IDENTITY:
*dst = *src;
break;
- case GSK_MATRIX_CATEGORY_2D_TRANSLATE:
+ case GSK_TRANSFORM_CATEGORY_2D_TRANSLATE:
*dst = *src;
dst->origin.x += head->metadata.translate_x;
dst->origin.y += head->metadata.translate_y;
break;
/* TODO: Handle scale */
- case GSK_MATRIX_CATEGORY_2D_AFFINE:
- case GSK_MATRIX_CATEGORY_UNKNOWN:
- case GSK_MATRIX_CATEGORY_ANY:
- case GSK_MATRIX_CATEGORY_INVERTIBLE:
+ case GSK_TRANSFORM_CATEGORY_UNKNOWN:
+ case GSK_TRANSFORM_CATEGORY_ANY:
+ case GSK_TRANSFORM_CATEGORY_3D:
+ case GSK_TRANSFORM_CATEGORY_2D:
+ case GSK_TRANSFORM_CATEGORY_2D_AFFINE:
default:
graphene_matrix_transform_bounds (builder->current_modelview,
src,
void
ops_set_modelview (RenderOpBuilder *builder,
const graphene_matrix_t *mv,
- GskMatrixCategory mv_category)
+ GskTransformCategory mv_category)
{
MatrixStackEntry *entry;
void
ops_push_modelview (RenderOpBuilder *builder,
const graphene_matrix_t *mv,
- GskMatrixCategory mv_category)
+ GskTransformCategory mv_category)
{
float scale = ops_get_scale (builder);
MatrixStackEntry *entry;
float dx_before;
float dy_before;
- GskMatrixCategory category;
+ GskTransformCategory category;
} OpsMatrixMetadata;
typedef struct
void ops_finish (RenderOpBuilder *builder);
void ops_push_modelview (RenderOpBuilder *builder,
const graphene_matrix_t *mv,
- GskMatrixCategory mv_category);
+ GskTransformCategory mv_category);
void ops_set_modelview (RenderOpBuilder *builder,
const graphene_matrix_t *mv,
- GskMatrixCategory mv_category);
+ GskTransformCategory mv_category);
void ops_pop_modelview (RenderOpBuilder *builder);
float ops_get_scale (const RenderOpBuilder *builder);
GSK_SERIALIZATION_INVALID_DATA
} GskSerializationError;
+/**
+ * GskTransformCategory:
+ * @GSK_TRANSFORM_CATEGORY_UNKNOWN: The category of the matrix has not been
+ * determined.
+ * @GSK_TRANSFORM_CATEGORY_ANY: Analyzing the matrix concluded that it does
+ * not fit in any other category.
+ * @GSK_TRANSFORM_CATEGORY_2D: The matrix is a 3D matrix. This means that
+ * the w column (the last column) has the values (0, 0, 0, 1).
+ * @GSK_TRANSFORM_CATEGORY_2D: The matrix is a 2D matrix. This is equivalent
+ * to graphene_matrix_is_2d() returning %TRUE. In particular, this
+ * means that Cairo can deal with the matrix.
+ * @GSK_TRANSFORM_CATEGORY_2D_AFFINE: The matrix is a combination of 2D scale
+ * and 2D translation operations. In particular, this means that any
+ * rectangle can be transformed exactly using this matrix.
+ * @GSK_TRANSFORM_CATEGORY_2D_TRANSLATE: The matrix is a 2D translation.
+ * @GSK_TRANSFORM_CATEGORY_IDENTITY: The matrix is the identity matrix.
+ *
+ * The categories of matrices relevant for GSK and GTK. Note that any
+ * category includes matrices of all later categories. So if you want
+ * to for example check if a matrix is a 2D matrix,
+ * `category >= GSK_TRANSFORM_CATEGORY_2D` is the way to do this.
+ *
+ * Also keep in mind that rounding errors may cause matrices to not
+ * conform to their categories. Otherwise, matrix operations done via
+ * mutliplication will not worsen categories. So for the matrix
+ * multiplication `C = A * B`, `category(C) = MIN (category(A), category(B))`.
+ */
+typedef enum
+{
+ GSK_TRANSFORM_CATEGORY_UNKNOWN,
+ GSK_TRANSFORM_CATEGORY_ANY,
+ GSK_TRANSFORM_CATEGORY_3D,
+ GSK_TRANSFORM_CATEGORY_2D,
+ GSK_TRANSFORM_CATEGORY_2D_AFFINE,
+ GSK_TRANSFORM_CATEGORY_2D_TRANSLATE,
+ GSK_TRANSFORM_CATEGORY_IDENTITY
+} GskTransformCategory;
+
#endif /* __GSK_TYPES_H__ */
graphene_matrix_to_float (&matrix, mat);
return g_variant_new (GSK_TRANSFORM_NODE_VARIANT_TYPE,
- gsk_transform_categorize (self->transform),
+ gsk_transform_get_category (self->transform),
(double) mat[0], (double) mat[1], (double) mat[2], (double) mat[3],
(double) mat[4], (double) mat[5], (double) mat[6], (double) mat[7],
(double) mat[8], (double) mat[9], (double) mat[10], (double) mat[11],
G_BEGIN_DECLS
-/*<private>
- * GskMatrixCategory:
- * @GSK_MATRIX_CATEGORY_UNKNOWN: The category of the matrix has not been
- * determined.
- * @GSK_MATRIX_CATEGORY_ANY: Analyzing the matrix concluded that it does
- * not fit in any other category.
- * @GSK_MATRIX_CATEGORY_INVERTIBLE: The matrix is linear independant and
- * should therefor be invertible. Note that this is not guaranteed
- * to actually be true due to rounding errors when inverting.
- * @GSK_MATRIX_CATEGORY_2D: The matrix is a 2D matrix. This is equivalent
- * to graphene_matrix_is_2d() returning %TRUE. In particular, this
- * means that Cairo can deal with the matrix.
- * @GSK_MATRIX_CATEGORY_2D_AFFINE: The matrix is a combination of 2D scale
- * and 2D translation operations. In particular, this means that any
- * rectangle can be transformed exactly using this matrix.
- * @GSK_MATRIX_CATEGORY_2D_TRANSLATE: The matrix is a 2D translation.
- * @GSK_MATRIX_CATEGORY_IDENTITY: The matrix is the identity matrix.
- *
- * The categories of matrices relevant for GSK and GTK. Note that any
- * category includes matrices of all later categories. So if you want
- * to for example check if a matrix is a 2D matrix,
- * `category >= GSK_MATRIX_CATEGORY_2D` is the way to do this.
- *
- * Also keep in mind that rounding errors may cause matrices to not
- * conform to their categories. Otherwise, matrix operations done via
- * mutliplication will not worsen categories. So for the matrix
- * multiplication `C = A * B`, `category(C) = MIN (category(A), category(B))`.
- */
-typedef enum
-{
- GSK_MATRIX_CATEGORY_UNKNOWN,
- GSK_MATRIX_CATEGORY_ANY,
- GSK_MATRIX_CATEGORY_INVERTIBLE,
- GSK_MATRIX_CATEGORY_2D_AFFINE,
- GSK_MATRIX_CATEGORY_2D_TRANSLATE,
- GSK_MATRIX_CATEGORY_IDENTITY
-} GskMatrixCategory;
-
typedef struct _GskRenderNodeClass GskRenderNodeClass;
#define GSK_IS_RENDER_NODE_TYPE(node,type) (GSK_IS_RENDER_NODE (node) && (node)->node_class->node_type == (type))
const char *type_name;
void (* finalize) (GskTransform *transform);
- GskMatrixCategory (* categorize) (GskTransform *transform);
+ GskTransformCategory (* categorize) (GskTransform *transform);
void (* to_matrix) (GskTransform *transform,
graphene_matrix_t *out_matrix);
gboolean (* apply_2d) (GskTransform *transform,
{
}
-static GskMatrixCategory
+static GskTransformCategory
gsk_identity_transform_categorize (GskTransform *transform)
{
- return GSK_MATRIX_CATEGORY_IDENTITY;
+ return GSK_TRANSFORM_CATEGORY_IDENTITY;
}
static void
GskTransform parent;
graphene_matrix_t matrix;
- GskMatrixCategory category;
+ GskTransformCategory category;
};
static void
{
}
-static GskMatrixCategory
+static GskTransformCategory
gsk_matrix_transform_categorize (GskTransform *transform)
{
GskMatrixTransform *self = (GskMatrixTransform *) transform;
switch (self->category)
{
- case GSK_MATRIX_CATEGORY_UNKNOWN:
- case GSK_MATRIX_CATEGORY_ANY:
- case GSK_MATRIX_CATEGORY_INVERTIBLE:
+ case GSK_TRANSFORM_CATEGORY_UNKNOWN:
+ case GSK_TRANSFORM_CATEGORY_ANY:
+ case GSK_TRANSFORM_CATEGORY_3D:
+ case GSK_TRANSFORM_CATEGORY_2D:
default:
return FALSE;
- case GSK_MATRIX_CATEGORY_2D_AFFINE:
+ case GSK_TRANSFORM_CATEGORY_2D_AFFINE:
*out_dx += *out_scale_x * graphene_matrix_get_value (&self->matrix, 3, 0);
*out_dy += *out_scale_y * graphene_matrix_get_value (&self->matrix, 3, 1);
*out_scale_x *= graphene_matrix_get_value (&self->matrix, 0, 0);
*out_scale_y *= graphene_matrix_get_value (&self->matrix, 1, 1);
return TRUE;
- case GSK_MATRIX_CATEGORY_2D_TRANSLATE:
+ case GSK_TRANSFORM_CATEGORY_2D_TRANSLATE:
*out_dx += *out_scale_x * graphene_matrix_get_value (&self->matrix, 3, 0);
*out_dy += *out_scale_y * graphene_matrix_get_value (&self->matrix, 3, 1);
return TRUE;
- case GSK_MATRIX_CATEGORY_IDENTITY:
+ case GSK_TRANSFORM_CATEGORY_IDENTITY:
return TRUE;
}
}
switch (self->category)
{
- case GSK_MATRIX_CATEGORY_UNKNOWN:
- case GSK_MATRIX_CATEGORY_ANY:
- case GSK_MATRIX_CATEGORY_INVERTIBLE:
- case GSK_MATRIX_CATEGORY_2D_AFFINE:
+ case GSK_TRANSFORM_CATEGORY_UNKNOWN:
+ case GSK_TRANSFORM_CATEGORY_ANY:
+ case GSK_TRANSFORM_CATEGORY_3D:
+ case GSK_TRANSFORM_CATEGORY_2D:
+ case GSK_TRANSFORM_CATEGORY_2D_AFFINE:
default:
return FALSE;
- case GSK_MATRIX_CATEGORY_2D_TRANSLATE:
+ case GSK_TRANSFORM_CATEGORY_2D_TRANSLATE:
*out_dx += graphene_matrix_get_value (&self->matrix, 3, 0);
*out_dy += graphene_matrix_get_value (&self->matrix, 3, 1);
return TRUE;
- case GSK_MATRIX_CATEGORY_IDENTITY:
+ case GSK_TRANSFORM_CATEGORY_IDENTITY:
return TRUE;
}
return TRUE;
GskTransform *
gsk_transform_matrix_with_category (GskTransform *next,
const graphene_matrix_t *matrix,
- GskMatrixCategory category)
+ GskTransformCategory category)
{
GskMatrixTransform *result = gsk_transform_alloc (&GSK_TRANSFORM_TRANSFORM_CLASS, next);
gsk_transform_matrix (GskTransform *next,
const graphene_matrix_t *matrix)
{
- return gsk_transform_matrix_with_category (next, matrix, GSK_MATRIX_CATEGORY_UNKNOWN);
+ return gsk_transform_matrix_with_category (next, matrix, GSK_TRANSFORM_CATEGORY_UNKNOWN);
}
/*** TRANSLATE ***/
{
}
-static GskMatrixCategory
+static GskTransformCategory
gsk_translate_transform_categorize (GskTransform *transform)
{
GskTranslateTransform *self = (GskTranslateTransform *) transform;
if (self->point.z != 0.0)
- return GSK_MATRIX_CATEGORY_INVERTIBLE;
+ return GSK_TRANSFORM_CATEGORY_3D;
- return GSK_MATRIX_CATEGORY_2D_TRANSLATE;
+ return GSK_TRANSFORM_CATEGORY_2D_TRANSLATE;
}
static void
{
}
-static GskMatrixCategory
+static GskTransformCategory
gsk_rotate_transform_categorize (GskTransform *transform)
{
- return GSK_MATRIX_CATEGORY_INVERTIBLE;
+ return GSK_TRANSFORM_CATEGORY_3D;
}
static void
{
}
-static GskMatrixCategory
+static GskTransformCategory
gsk_scale_transform_categorize (GskTransform *transform)
{
GskScaleTransform *self = (GskScaleTransform *) transform;
if (self->factor_z != 1.0)
- return GSK_MATRIX_CATEGORY_INVERTIBLE;
+ return GSK_TRANSFORM_CATEGORY_3D;
- return GSK_MATRIX_CATEGORY_2D_AFFINE;
+ return GSK_TRANSFORM_CATEGORY_2D_AFFINE;
}
static void
return first->transform_class->equal (first, second);
}
-/*<private>
- * gsk_transform_categorize:
- * @self: (allow-none): A matrix
- *
+/**
+ * gsk_transform_get_category:
+ * @self: (allow-none): A #GskTransform
*
+ * Returns the category this transform belongs to.
*
- * Returns: The category this matrix belongs to
+ * Returns: The category of the transform
**/
-GskMatrixCategory
-gsk_transform_categorize (GskTransform *self)
+GskTransformCategory
+gsk_transform_get_category (GskTransform *self)
{
if (self == NULL)
- return GSK_MATRIX_CATEGORY_IDENTITY;
+ return GSK_TRANSFORM_CATEGORY_IDENTITY;
- return MIN (gsk_transform_categorize (self->next),
+ return MIN (gsk_transform_get_category (self->next),
self->transform_class->categorize (self));
}
#error "Only <gsk/gsk.h> can be included directly."
#endif
+#include <gsk/gskenums.h>
#include <gsk/gsktypes.h>
G_BEGIN_DECLS
float *out_dx,
float *out_dy) G_GNUC_WARN_UNUSED_RESULT;
+GDK_AVAILABLE_IN_ALL
+GskTransformCategory gsk_transform_get_category (GskTransform *self) G_GNUC_PURE;
GDK_AVAILABLE_IN_ALL
gboolean gsk_transform_equal (GskTransform *first,
GskTransform *second) G_GNUC_PURE;
G_BEGIN_DECLS
-GskMatrixCategory gsk_transform_categorize (GskTransform *self);
-
GskTransform * gsk_transform_matrix_with_category (GskTransform *next,
const graphene_matrix_t*matrix,
- GskMatrixCategory category);
+ GskTransformCategory category);
G_END_DECLS
void
gtk_snapshot_transform_matrix_with_category (GtkSnapshot *snapshot,
const graphene_matrix_t *matrix,
- GskMatrixCategory category)
+ GskTransformCategory category)
{
GtkSnapshotState *state;
void gtk_snapshot_transform_matrix_with_category
(GtkSnapshot *snapshot,
const graphene_matrix_t*matrix,
- GskMatrixCategory category);
+ GskTransformCategory category);
void gtk_snapshot_append_text (GtkSnapshot *snapshot,
PangoFont *font,
PangoGlyphString *glyphs,
graphene_matrix_init_translate (&priv->transform, &GRAPHENE_POINT3D_INIT (adjusted.x, adjusted.y, 0));
gsk_transform_to_matrix (transform, &transform_matrix);
graphene_matrix_multiply (&priv->transform, &transform_matrix, &priv->transform);
- priv->transform_category = gsk_transform_categorize (transform);
+ priv->transform_category = gsk_transform_get_category (transform);
if (adjusted.x || adjusted.y)
- priv->transform_category = MIN (priv->transform_category, GSK_MATRIX_CATEGORY_2D_TRANSLATE);
+ priv->transform_category = MIN (priv->transform_category, GSK_TRANSFORM_CATEGORY_2D_TRANSLATE);
if (!alloc_needed && !size_changed && !baseline_changed)
{
gint allocated_size_baseline;
graphene_matrix_t transform;
- GskMatrixCategory transform_category;
+ GskTransformCategory transform_category;
int width;
int height;
int baseline;
case GSK_TRANSFORM_NODE:
{
static const char * category_names[] = {
- [GSK_MATRIX_CATEGORY_UNKNOWN] = "unknown",
- [GSK_MATRIX_CATEGORY_ANY] = "any",
- [GSK_MATRIX_CATEGORY_INVERTIBLE] = "invertible",
- [GSK_MATRIX_CATEGORY_2D_AFFINE] = "2D affine",
- [GSK_MATRIX_CATEGORY_2D_TRANSLATE] = "2D transform",
- [GSK_MATRIX_CATEGORY_IDENTITY] = "identity"
+ [GSK_TRANSFORM_CATEGORY_UNKNOWN] = "unknown",
+ [GSK_TRANSFORM_CATEGORY_ANY] = "any",
+ [GSK_TRANSFORM_CATEGORY_3D] = "3D",
+ [GSK_TRANSFORM_CATEGORY_2D] = "2D",
+ [GSK_TRANSFORM_CATEGORY_2D_AFFINE] = "2D affine",
+ [GSK_TRANSFORM_CATEGORY_2D_TRANSLATE] = "2D translate",
+ [GSK_TRANSFORM_CATEGORY_IDENTITY] = "identity"
};
GskTransform *transform;
char *s;
s = gsk_transform_to_string (transform);
add_text_row (store, "Matrix", s);
g_free (s);
- add_text_row (store, "Category", category_names[gsk_transform_categorize (transform)]);
+ add_text_row (store, "Category", category_names[gsk_transform_get_category (transform)]);
}
break;